 <?php 
App::uses('Component', 'Controller');
 
class CodeComponent extends Component  {
 
/**
 * Password generator function
 *
 */
    function generateCode ($length = 5){
        // inicializa variables
        $code = "";
        $i = 0;
        $possible = "0123456789bcdfghjkmnpqrstvwxyz"; 
        
        // agrega random
        while ($i < $length){
            $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
            
            if (!strstr($code, $char)) { 
                $code .= $char;
                $i++;
            }
        }
        return $code;
    }
}
?> 